package com.hyfrogx.modules.charge.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyfrogx.common.exception.ServiceException;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.modules.charge.dao.HyChargeDao;
import com.hyfrogx.modules.charge.entity.HyCharge;
import com.hyfrogx.modules.charge.service.HyChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：Li9527
 * @date ：Created in 2019-11-22 14:35
 * @description：${description}
 * @modified By：
 * @version: 1.0.0
 */
@Service("HyChargeService")
public class HyChargeServiceImpl extends ServiceImpl<HyChargeDao, HyCharge> implements HyChargeService {


    @Override
    public Page selectPageByConditions(QueryExt query) {
        Map map = new HashMap();
        map.putAll(query.getCondition());
        query.setRecords(this.baseMapper.selectPageByConditions(query, map));
        return query;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(HyCharge charge) {
        this.baseMapper.updateSort(charge.getId());
        this.baseMapper.deleteById(charge.getId());
    }
}
